package dev.erge.net;

import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;

public class TCPServerSample {
    public static void main(String[] args) {
        try {
            // 创建服务器
            ServerSocket serverSocket = new ServerSocket(8088);
            // 创建socket
            Socket socket = new Socket();
            while (true) {
                // 监听
                socket = serverSocket.accept();
                TCPServerThreadSample thread = new TCPServerThreadSample(socket);
                thread.start();
                InetAddress address = socket.getInetAddress();
                System.out.println("当前客户端ip:" + address.getHostAddress());
            }
        } catch (IOException e) {
        }

    }
}